<?php 
if(!empty($_POST))
{
	$errors = '';

	$myemail = 'narguedas@starscamp.net';//<-----Put Your email address here.
	if(empty($_POST['T1']))
	{
		$errors .= "\n Error: all fields are required";
	}
	$email_address = $_POST['T1'];
	
	if (!preg_match(
	"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
	$email_address))
	{
		$errors .= "\n Error: Invalid email address";
	}
	
	if( empty($errors))
	{
		$to_adm = $myemail; 
		$email_subject_adm = "Starscamp - Newsletter";
		$email_body_adm = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Formulario de contacto</title>
		</head>
		
		<body>
			  <table align=center width=100% style="padding:20px;" >
		<tr><td>
		<table align=center width=560 style="font-family:sans-serif; color:#FFF; background-color:#335259;">         
		<tr><td colspan=3 height=20></td></tr>        
        <tr>
        	<td width=20></td>
			<td><p><img src="http://starscamp.net/img/logo.png" alt=Starscamp></p>
		<h2 style="color:#fff;">Newsletter</h2>
			<p style="color:#fff;">
				Una persona se ha suscrito al Newsletter de Starscamp.			
			</p>
			<p><strong>Email:<strong> <a style="color:#FFF"; href="mailto:'.$email_address.'">'.$email_address.'</a></p>	
            </td>
            <td width=20></td>
       </tr>       
       <tr><td colspan=3 height=20></td></tr>        
		</table>	
		</td></tr>
		</table>
		</body>
		<html>';
		
		$to_cli = $email_address; 
		$email_subject_cli = "Starscamp - Newsletter";
		$email_body_cli = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Formulario de contacto</title>
		</head>
		
		<body>
			            <table align=center width=100% style="padding:20px;" >
		<tr><td>
		<table align=center width=560 style="font-family:sans-serif; color:#FFF; background-color:#335259;">         
		<tr><td colspan=3 height=20></td></tr>        
        <tr>
        	<td width=20></td>
			<td><p><img src="http://starscamp.net/img/logo.png" alt=Starscamp></p>
			
			<h2 style="color:#fff;">Hola '.$name.'</h2>
			<p style="color:#fff;">
				Gracias por escribirnos, muy pronto
				nos pondremos en contacto contigo
				para responderte.
			</p>
			<p style="color:#fff;">
				General Trinidad Morán 990 - Lince. Lima-Perú.<br>
				T/ (01) 624 1608
			</p>
            </td>
            <td width=20></td>
       </tr>       
       <tr><td colspan=3 height=20></td></tr>        
		</table>	
		</td></tr>
		</table>
		</body>
		<html>';

		$headers = "Organization: Starscamp\r\n";	
		$headers .= "MIME-Version: 1.0\r\n"; 
		$headers .= "Content-type: text/html; charset=utf-8\r\n";
		$headers .= "X-Priority: 3\r\n";
		$headers .= "X-Mailer: PHP". phpversion() ."\r\n"; 	
		$headers .= "From: Starscamp <$myemail>\r\n"; 
		$headers .= "Reply-To: $email_address\r\n";
		$headers .= "Return-Path: <$myemail>\r\n";
		
		if(mail($to_adm, $email_subject_adm, $email_body_adm, $headers) &&
		mail($to_cli, $email_subject_cli, $email_body_cli, $headers))
		{
			echo "<p> <strong style='color:#fff;'>
			Gracias, te has inscrito a nuestro newsletter.</strong></p>";
		}
		else {
			echo "<p><strong style='color:#fff;'>
			Lo sentimos, se ha producido un error.</strong><p>";	
		}
	}
}
?>